package jy.game.components.wuxue;

import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

import jy.game.tools.Tools;

public class JyBuff {
    public static String[] BuffNames   = new String[]{
        "恢复", "集气", "攻击强化", "飘渺", "左右互搏", "神速攻击", "醉酒", "溜须拍马", "易容",
        "狂战", "坚守", "沾衣十八跌", "圣战", "轻身", "防御强化", "魔神降临", "神行", "不动如山"};
    public static String[] DebuffNames = new String[]{
        "中毒", "内伤", "致盲", "缓速", "晕眩", "攻击弱化", "诸般封印", "剑封印",
        "刀封印", "拳掌封印", "奇门封印", "仙术封印", "伤害加深", "重伤", "定身",
        "封穴", "点穴", "诅咒", "麻痹"};
    // Token: 0x04000291 RID: 657
    public        String   Name;
    // Token: 0x04000292 RID: 658
    public        int      Level;
    // Token: 0x04000293 RID: 659
    public        int      Round       = -1;
    // Token: 0x04000294 RID: 660
    public        int      Property    = -1;

    JyBuff(String name, int level, int round, int property) {
        this.Name = name;
        this.Level = level;
        this.Round = round;
        this.Property = property;
    }

    // Token: 0x060003AB RID: 939 RVA: 0x00029CF0 File Offset: 0x00027EF0
    public static String BuffsToString(List<JyBuff> buffs) {
        if (buffs.size() > 0) {
            String text = "";
            for (JyBuff buff : buffs) {
                text += String.format("#%s.%s.%s.%s",
                    buff.Name,
                    buff.Level,
                    buff.Round,
                    buff.Property
                );
            }
            text = Tools.trimStart(text, '#');
            return text;
        }
        return "";
    }

    // Token: 0x060003AD RID: 941 RVA: 0x00029DF4 File Offset: 0x00027FF4
    public static Iterable<JyBuff> Parse(String content) {
        if (TextUtils.isEmpty(content)) {
            return null;
        }
        String[]     tmp   = content.split("#");
        List<JyBuff> buffs = new ArrayList<>();
        for (String s : tmp) {
            String[] paras    = s.split("\\.");
            String   name     = paras[0];
            int      level    = 1;
            int      round    = 3;
            int      property = -1;
            if (paras.length > 1) {
                level = Integer.parseInt(paras[1]);
            }
            if (paras.length > 2) {
                round = Integer.parseInt(paras[2]);
            }
            if (paras.length > 3) {
                property = Integer.parseInt(paras[3]);
            }
            buffs.add(new JyBuff(name, level, round, property));
        }
        return buffs;
    }

    // Token: 0x170000B4 RID: 180
    // (get) Token: 0x060003AC RID: 940 RVA: 0x00029DB4 File Offset: 0x00027FB4
    public boolean getIsDebuff() {
        {
            for (String value : JyBuff.BuffNames) {
                if (this.Name.equals(value)) {
                    return false;
                }
            }
            return true;
        }
    }
}
